package com.github.coolcool.sloth.lianjiadb.service.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import com.github.coolcool.sloth.lianjiadb.mapper.HouseMapper;
import com.github.coolcool.sloth.lianjiadb.model.House;
import com.github.coolcool.sloth.lianjiadb.service.HouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.coolcool.sloth.lianjiadb.common.Page;
import javax.annotation.Generated;


@Generated(
	value = {
		"https://github.com/coolcooldee/sloth",
		"Sloth version:1.0"
	},
	comments = "This class is generated by Sloth"
)
@Service
public  class HouseServiceImpl implements HouseService{

	Logger logger = LoggerFactory.getLogger(HouseService.class);

	@Autowired
	private HouseMapper houseMapper;

	public Integer save(House house){
		return houseMapper.insert(house);
	}

	@Override
	public House getById(Object id){
		return houseMapper.getByPrimaryKey(id);
	}

	@Override
	public House getByCode(String code){
		return houseMapper.getByCode(code);
	}

	@Override
	public void deleteById(Object id){
		houseMapper.deleteByPrimaryKey(id);
	}
	@Override
	public void update(House house){
		houseMapper.updateByPrimaryKey(house);
	}

	@Override
	public Integer count(){
	    return houseMapper.count();
	}

	@Override
	public List<House> list(){
		return houseMapper.list();
	}

	@Override
	public Page<House> page(int pageNo, int pageSize) {
		Page<House> page = new Page<>();
        int start = (pageNo-1)*pageSize;
        page.setPageSize(pageSize);
        page.setStart(start);
        page.setResult(houseMapper.page(start,pageSize));
        page.setTotalCount(houseMapper.count());
        return page;
	}

	@Override
	public Page<House> pageToday(int pageNo, int pageSize){
		Page<House> page = new Page<>();
		int start = (pageNo-1)*pageSize;
		page.setPageSize(pageSize);
		page.setStart(start);
		page.setResult(houseMapper.pageToday(start,pageSize));
		page.setTotalCount(houseMapper.count());
		return page;
	}

	@Override
	public Integer increment(){
		return houseMapper.increment();
	}
	
}